/*
  * Copyright (c) 2025 Huawei Device Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
    *
  * http://www.apache.org/licenses/LICENSE-2.0
    *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  * */

// automatically generated by the FlatBuffers compiler, do not modify

/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */

import { MessageEvent } from '../notification/message-event.js';
import { StatusEvent } from '../notification/status-event.js';


export enum EventUnion {
  NONE = 0,
  MessageEvent = 1,
  StatusEvent = 2
}

export function unionToEventUnion(
  type: EventUnion,
  accessor: (obj:MessageEvent|StatusEvent) => MessageEvent|StatusEvent|null
): MessageEvent|StatusEvent|null {
  switch(EventUnion[type]) {
    case 'NONE': return null; 
    case 'MessageEvent': return accessor(new MessageEvent())! as MessageEvent;
    case 'StatusEvent': return accessor(new StatusEvent())! as StatusEvent;
    default: return null;
  }
}

export function unionListToEventUnion(
  type: EventUnion, 
  accessor: (index: number, obj:MessageEvent|StatusEvent) => MessageEvent|StatusEvent|null, 
  index: number
): MessageEvent|StatusEvent|null {
  switch(EventUnion[type]) {
    case 'NONE': return null; 
    case 'MessageEvent': return accessor(index, new MessageEvent())! as MessageEvent;
    case 'StatusEvent': return accessor(index, new StatusEvent())! as StatusEvent;
    default: return null;
  }
}
